/*
 * @Description: 
 * @FilePath: /STM32/USER/my_include.h
 * @Author: Wei Zhou
 * @Github: https://github.com/zromyk
 * @Date: 2021-04-28 15:25:19
 * @LastEditors: Wei Zhou
 * @LastEditTime: 2021-04-28 22:00:25
 * @Copyright: Copyright  2017 muyiro. All rights reserved.
 */

#ifndef MY_INCLUDE_H
#define MY_INCLUDE_H

// #include "stm32f4xx_conf.h"
#include "stm32f4xx.h"

#define MATH_PI             (3.1415926)

#define _abs(x)             ((x) > 0 ? (x) : (-(x)))
#define _max(x, y)          (((x) > (y)) ? (x) : (y))    // maximum value
#define _min(x, y)          (((x) < (y)) ? (x) : (y))    // minimum value

#define _imax(x, y)         (((x) > (y)) ? (x) : (y))
#define _imin(x, y)         (((x) < (y)) ? (x) : (y))
#define _imid(a, b, c)      (b < c ? _limit(a, b, c) : _limit(a, c, b))     // intermediate value

#define _iinc(i, a, b)      (i <= _imax(a, b) && i >= _imin(a, b)) 
#define _iexc(i, a, b)      (i > _imax(a, b) || i < _imin(a, b))
#define _ninc(i, a, b)      (i >= a && i <= b)

#define _iiabs(x)           (((int)(x) > 0) ? (int)(x) : (-(int)(x)))
#define _iidif(x, y)        _iiabs((int)(x - y))

#define _limit(a, b, c)     (a > b ? (a < c ? a : c) : b)

#endif /* MY_INCLUDE_H */
